﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Cinema._Desk
{
    /// <summary>
    /// Interaction logic for DeskType.xaml
    /// </summary>
    public partial class Type : Page
    {
        public StackPanel MainMenu { get; set; }
        public Type()
        {
            InitializeComponent();
            (DataContext as Bussiness.Cinema.DeskType).Messenger.Register<Bussiness.Cinema.Message.DeleteConfirmation>(this, ShowMessageBox1);
            (DataContext as Bussiness.Cinema.DeskType).Messenger.Register<Bussiness.Cinema.Message.DeleteDeskTypeFailed>(this, ShowMessageBox2);
            Loaded += Type_Loaded;
            Unloaded += Type_Unloaded;
        }

        void Type_Unloaded(object sender, RoutedEventArgs e)
        {
            (DataContext as Bussiness.Cinema.DeskType).IsViewing = false;
        }

        void Type_Loaded(object sender, RoutedEventArgs e)
        {
            (DataContext as Bussiness.Cinema.DeskType).IsViewing = true;
        }
        void ShowMessageBox1(Bussiness.Cinema.Message.DeleteConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgCinemaDeskTypeDelete") as String), "", MessageBoxButton.YesNo);
        }
        void ShowMessageBox2(Bussiness.Cinema.Message.DeleteDeskTypeFailed s)
        {
            MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgCinemaDeskTypeNotDelete") as String), "", MessageBoxButton.OK);
        }
        private void DataGrid_CurrentCellChanged(object sender, EventArgs e)
        {
            (DataContext as Bussiness.Cinema.DeskType).SaveCommand.Execute(((sender as DataGrid).SelectedItem));
        }

    }
}
